<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

<a:loadScript src="js/sw-util.js" />
<a:loadScript src="js/jquery.maskedinput-1.3.js" />
<a:loadScript src="js/jquery.maskedinput-1.1.4.pack.js" />




    <h:form id="clientePJForm">

        <rich:panel>
            <f:facet name="header">Cliente Pessoa Juridica</f:facet>
        

				<fieldset id="child">
				<legend>Dados da Empresa</legend>
				<ul>
			            <s:decorate id="nomeFantasiaField" template="layout/edit.xhtml">
			                <ui:define name="label">Nome Fantasia</ui:define>
			                <h:inputText id="nomeFantasia" 
			                             value="#{clientePJ.nomeFantasia}" style=" width : 532px;"/>
			            </s:decorate>
			            
			            <s:decorate id="razaoSocialField" template="layout/edit.xhtml">
			                <ui:define name="label">Razao Social</ui:define>
			                <h:inputText id="razaoSocial" required="true"
			                             value="#{clientePJ.razaoSocial}" style=" width : 532px;"/>
			            </s:decorate>
			            
			            <s:decorate id="cnpjField" template="layout/edit.xhtml">
			                <ui:define name="label">CNPJ</ui:define>
			                <h:inputText id="cnpj" required="true"
			                             value="#{clientePJ.cnpj}"  maxlength="21" size="21" >
			                             <rich:jQuery selector="#cnpj" query="mask('99.999.999/9999-99')" timing="onload"></rich:jQuery>
			                </h:inputText>
			            </s:decorate>
			            
			            <s:decorate id="nomeResponsavelLegalField" template="layout/edit.xhtml">
			                <ui:define name="label">Responsavel Legal</ui:define>
			                <h:inputText id="nomeResponsavelLegal" required="true"
			                             value="#{clientePJ.nomeResponsavelLegal}" style=" width : 532px;"/>
			            </s:decorate>	

			            <s:decorate id="cpfResponsavelLegalField" template="layout/edit.xhtml">
			                <ui:define name="label">CPF Responsavel Legal</ui:define>
			                <h:inputText id="cpfResponsavelLegal" required="true"
			                             value="#{clientePJ.cpfResponsavelLegal}"  size="18" maxlength="14">
			                             <rich:jQuery selector="#cpfResponsavelLegal" query="mask('999.999.999-99')" timing="onload"></rich:jQuery>
			                </h:inputText>
			            </s:decorate>
			            
			            
			            <s:decorate id="dataFundacaoField" template="layout/edit.xhtml">     
					         <ui:define name="label">Data Fundacao</ui:define>    
				             <h:inputText id="dataFundacao" 
				                    value="#{clientePJ.dataFundacao}" >
				              <s:convertDateTime pattern="dd/MM/yyyy" type="date" />
			                  <rich:jQuery selector="#dataFundacao" query="mask('99/99/9999')" timing="onload"></rich:jQuery>
				              </h:inputText>
						</s:decorate>		

				</ul>
				</fieldset>		
			            
				<fieldset id="child">
				<legend>Endereco</legend>
				<ul>
						
			            <s:decorate id="ufField" template="/layout/edit.xhtml">
			                <ui:define name="label">Estado</ui:define>
			                <h:selectOneMenu id="ufFieldId" value="#{cidadeList.uf}"  required="true" >
			                	<s:selectItems value="#{ufs}" var="_uf" itemLabel="#{_uf.nome}" itemValue="#{_uf}" label="#{_uf.nome}" hideNoSelectionLabel="false" noSelectionLabel="Selecione"/>
			                	<s:convertEntity/>
			                	<a:support event="onchange" reRender="cidadeField" ajaxSingle="true" requestDelay="200" action="#{cidadeList.buscaCidade()}"/>
			                </h:selectOneMenu>
			            </s:decorate>
			            
			            <s:decorate id="cidadeField" template="/layout/edit.xhtml">
			                <ui:define name="label">Cidade</ui:define>
			                <h:selectOneMenu id="cidadeFieldId" value="#{clientePJ.cidade}"  required="true" rendered="#{ cidadeList.uf != null }">
			                	<s:selectItems value="#{cidades}" var="_cidade" itemLabel="#{_cidade.nome}" itemValue="#{_cidade}" label="#{_cidade.nome}"  />
			                	<s:convertEntity/>
			                </h:selectOneMenu>
			            </s:decorate>	       

			            <s:decorate id="logradouroField" template="layout/edit.xhtml">
			                <ui:define name="label">Logradouro</ui:define>
			                <h:inputText id="logradouro"  required="true"
			                             value="#{clientePJ.logradouro}" style=" width : 520px;"/>
			            </s:decorate>   
 
			            <s:decorate id="numeroField" template="layout/edit.xhtml">
			                <ui:define name="label">Numero</ui:define>
			                <h:inputText id="numero"  required="true"
			                             value="#{clientePJ.numero}" OnKeyPress="return SomenteNumero()" >
			                </h:inputText>
			                             
			            </s:decorate>   
			            
			            <s:decorate id="complementoField" template="layout/edit.xhtml">
			                <ui:define name="label">Complemento</ui:define>
			                <h:inputText id="complemento" 
			                             value="#{clientePJ.complemento}" style=" width : 511px;"/>
			            </s:decorate>               
			            
			            <s:decorate id="bairroField" template="layout/edit.xhtml">
			                <ui:define name="label">Bairro</ui:define>
			                <h:inputText id="bairro"   required="true"
			                             value="#{clientePJ.bairro}"/>
			            </s:decorate>     
			             
			            <s:decorate id="cepField" template="layout/edit.xhtml">
			                <ui:define name="label">CEP</ui:define>
			                <h:inputText id="cep" 
			                             value="#{clientePJ.cep}" style=" width : 135px;">
			                             <rich:jQuery selector="#cep" query="mask('99999-999')" timing="onload"></rich:jQuery>
			                </h:inputText>             			                             
			            </s:decorate>  
				</ul>  
				</fieldset>   
				
				<fieldset id="child">
    			<legend>Contato</legend>
                <ul>				
			            <s:decorate id="emailField" template="layout/edit.xhtml">
			                <ui:define name="label">E-mail</ui:define>
			                <h:inputText id="email" 
			                             value="#{clientePJ.email}" style=" width : 335px;"/>
			            </s:decorate>  
			
			            <s:decorate id="fone1Field" template="layout/edit.xhtml">
			                <ui:define name="label">Fone 1</ui:define>
			                <h:inputText id="fone1" 
			                             value="#{clientePJ.fone1}" required="true">			                             			                             
			                             <rich:jQuery selector="#fone1" query="mask('(99)9999-9999')" timing="onload"></rich:jQuery>
			                </h:inputText>             
			            </s:decorate>  
			            
			            <s:decorate id="fone2Field" template="layout/edit.xhtml">
			                <ui:define name="label">Fone 2</ui:define>
			                <h:inputText id="fone2" 
			                             value="#{clientePJ.fone2}">
			                             <rich:jQuery selector="#fone2" query="mask('(99)9999-9999')" timing="onload"></rich:jQuery>
							</h:inputText>			                             
			            </s:decorate>              
			
			            <s:decorate id="fone3Field" template="layout/edit.xhtml">
			                <ui:define name="label">Fone 3</ui:define>
			                <h:inputText id="fone3" 
			                             value="#{clientePJ.fone3}">
			                             <rich:jQuery selector="#fone3" query="mask('(99)9999-9999')" timing="onload"></rich:jQuery>	
							</h:inputText>			                                   
			            </s:decorate>  
			            
			    </ul>
				</fieldset>   
				
            <div style="clear:both"/>

        </rich:panel>
        
			

        <div class="actionButtons">
            <h:commandButton id="save"
                          value="Salvar"
                         action="#{ClientePJBean.novoCliente}"/>
            <s:button propagation="end"
                               id="cancel"
                            value="Cancelar"
                             view="/home.xhtml"/>
        </div>

    </h:form>

</ui:define>

</ui:composition>
